package com.sos.utils
{
	import flash.display.Sprite;
	
	import mx.controls.Alert;
	import mx.core.IVisualElement;
	import mx.core.IVisualElementContainer;
	import mx.core.UIComponent;
	

	public class UIUtils
	{
		
		public static function getElementById(container:IVisualElementContainer, id:String):IVisualElement
		{
			for (var i:int=0; i<container.numElements; i++)
			{
				var cmp:UIComponent = container.getElementAt(i) as UIComponent;
				if (cmp.id == id) return cmp as IVisualElement;
			}
			return null;
		}
		
		public static function confirm(message:String, title:String, callback:Function, parent:Sprite = null):void
		{
			Alert.show(message, title, Alert.OK | Alert.CANCEL, parent, callback);
		}
		
		public static function warning(message:String, title:String = ""):void
		{
			Alert.show(message, title, Alert.OK);
		}
		
		public static function error(message:String, title:String = ""):void
		{
			Alert.show(message, title, Alert.OK);
		}
		
		public static function yesNoCancel(message:String, title:String, callback:Function, parent:Sprite = null):void
		{
			Alert.show(message, title, Alert.YES | Alert.NO | Alert.CANCEL, parent, callback);
		}
		
	}
}